package org.example.frame.starters.idempotent.core.token;

import java.util.ArrayList;
import java.util.List;

public class Test {

    public static List<List<Integer>> permute(int[] nums){
        List<List<Integer>> res = new ArrayList<>();
        List<Integer> cur = new ArrayList<>();
        backTracking(res, cur,nums);
        return res;
    }

    public static void backTracking(List<List<Integer>> res, List<Integer> cur, int[] nums){
        if (cur.size() == nums.length){
            res.add(new ArrayList<>(cur));
            return;
        }
        for (int i = 0; i < nums.length; i++) {
            if(!cur.contains(nums[i])){
                cur.add(nums[i]);
                backTracking(res, cur, nums);
                cur.remove(cur.size() - 1);
            }
        }
    }

    public static void main(String[] args) {

    }
}
